//
//  HandleManager.m
//  Void Dead
//
//  Created by Sidney Just on 02.07.09.
//  Copyright 2009 by Sidney Just
//  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; 
//  either version 3 of the License, or (at your option) any later version.
//  
//  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
//  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//  


NSMutableArray *handles;

#pragma mark -
#pragma mark init dealloc

/** 
 * inits the handle manager. This is done by the engine
 **/
void initHandleManager() 
{
	handles = [[NSMutableArray alloc] init];
}

/** 
 * deletes the handle manager. This is done by the engine
 **/
void removeHandleManager() 
{
	[handles release];
}

#pragma mark -
#pragma mark handle functions

/** 
 * gives the pointer to the object associated with the handel
 @param handle the handle
 @return pointer to the handle
 **/
id ptr_for_handle(int handle)
{
	return [handles objectAtIndex:handle];
}

/** 
 * gives a handle to a given pointer
 @param ptr pointer which will be used to create the handle
 @return handle to the pointer
 **/
int ptr_to_handle(id ptr) 
{
	[handles addObject:ptr];
	return [handles count]-1;
}


